package com.beta.vo.product;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Getter;
import lombok.Setter;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;

import java.math.BigDecimal;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

/**
 * Created by vector on 2017/1/6.
 */
@Getter
@Setter
public class ProductItemVO {

    private Integer id;

    private String sku;

    private String name;

    private String userName;

    private BigDecimal price;

    private BigDecimal quantity;

    private String chargeUnit;

    private String posterUrl;

    private String origin;

    private String level;

    private String productDesc;

    private String specDesc;

    private String saleStatus;

    private String saleStatusText;

    @JsonProperty("slide_img_path")
    private List<String> slideImages;

    public BigDecimal getInventoryQty() {
        return getQuantity();
    }

    public String getMerchantName() {
        return getUserName();
    }

    public String getProductName() {
        return this.getName();
    }

    public List<String> getSlideImages() {
        if (CollectionUtils.isEmpty(slideImages)) {
            return Collections.emptyList();
        }
        return slideImages.stream().filter(StringUtils::isNoneBlank).collect(Collectors.toList());
    }

}
